define(["jquery","bbcare"],function($,$bb){
	var servers = {};
	var URL = $bb.baseUrl("followapp");

	/**
	 * 查询节点
	 */
	servers.ajaxNodes = function(params,callback){
		$bb.ajax({
			url: URL + "ctrl/ptmanage/qryUserCpNodeList",
			data:JSON.stringify({
				data : {
					"userId":params.userId,
				}
			}),
			success: function(data){
				if(data.success){
					callback(data.data,params);
				}else{
					$bb.toastShow(data.msg ? data.msg : "查询节点失败！");
				}
			}
		});
	};
	/**
	 * 查询任务根据节点
	 */
	servers.ajaxTasks = function(params,callback){
		$bb.ajax({
			url: URL + "ctrl/ptmanage/qryUserCpTaskList",
			data:JSON.stringify({
				data : {
					"ptNodeId":params.ptNodeId,
				}
			}),
			success: function(data){
				if(data.success){
					callback(data.data,params);
				}else{
					$bb.toastShow(data.msg ? data.msg : "查询任务根据节点失败！");
				}
			}
		});
	};
	/**
	 * 查询问卷
	 */
	servers.ajaxTaskContTempl = function(params,callback){
		$bb.ajax({
			url: URL + "ctrl/ptmanage/qryUserCpTaskCont",
			data:JSON.stringify({
				data : {
					"ptTaskId":params.ptTaskId,
				}
			}),
			success: function(data){
				if(data.success){
					callback(data.data,params);
				}else{
					$bb.toastShow(data.msg ? data.msg : "查询问卷出错！");
				}	
			}
		});
	}

	/**
	 * 任务提交
	 */
	servers.ajaxSubmitTask = function(params,callback,domId){
		$bb.ajax({
			url: URL + "ctrl/ptmanage/submitUserCpTask",
			data:JSON.stringify({
				data : params
			}),
			success: function(data){
				if(data.success){
					callback(data.data,params,domId);
				}else{
					$bb.toastShow(data.msg ? data.msg : "任务提交失败！");
				}
			}
		});
	};

	return servers;
});